import type { ApiInfoVO } from "../apiInfo/types";
import axios from "../axios";
import type { MenuVO } from "../menu/types";
import type { RoleAuthVO } from "./types";

const prefix = `${import.meta.env.VITE_APP_API_URL}/role/auth`
class AuthController {
  detail(role: string) {
    return axios.get<RoleAuthVO>(`${prefix}/detail`, { role });
  }
  list() {
    return axios.get<RoleAuthVO[]>(`${prefix}/list`, {});
  }
  updateMenuAuth(role: string, roleName: string, roleAuthMenus: MenuVO[]) {
    return axios.post(`${prefix}/updateMenuAuth`, { role, roleName, menus: roleAuthMenus })
  }
  updateApiAuth(role: string, roleName: string, apis: ApiInfoVO[]) {
    return axios.post(`${prefix}/updateApiAuth`, { role, roleName, apis: apis })
  }
  checkMenuAuth(menuCode: string) {
    return axios.get<boolean>(`${prefix}/checkMenuAuth`, { menuCode });
  }
}

export default AuthController;
